﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections;
using System.Runtime;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using Cmd.TypeConverters;

namespace Cmd
{
    public abstract class BaseTypeConverter<T> : ITypeConverter<T>
    {
        public Type BaseType { get; private set; }


        public BaseTypeConverter()
        {
            BaseType = typeof(T);
        }

        public static ITypeConverter GetConverter(Type type)
        {
            return TypeConverterHelpers.GetConverter(type);
        }

        public static void RegisterConverter(ITypeConverter converter)
        {
            TypeConverterHelpers.RegisterConverter(converter);
        }

        public abstract T ConvertFromString(string value);
        public abstract string ConvertToString(object value);

        object ITypeConverter.ConvertFromString(string value)
        {
            return (T)ConvertFromString(value);
        }
    }
}
